import java.util.*;

/**
 * Created by xiebang
 * Description
 * User:小谢
 * Date:2021-09-22
 * Time:19:50
 */
public class TestDemo {
    public static void main3(String[] args) {
        Map<String,String> map = new HashMap<>();
        map.put("国民女神","兵姐姐");
        map.put("国民男神","兵哥哥");
        System.out.println(map);
        map.put("沙僧","悟净");
        map.put("孔明","诸葛亮");

        // map 存储的数据是无序的（不是大小顺序）
        //put 存放值是有一定规则的
        //hasmap中key值是可以重复的，但是最后你存储的是最后更新的value 值
        //value 值也是可以重复的，不会被替换
        System.out.println(map);
        String v = map.get("国民男神");
        System.out.println(v);
        String v1 = map.getOrDefault("国民男神2","高博");
        System.out.println(v1);
        System.out.println(map.size());
        System.out.println("======================================");
        System.out.println(map.containsKey("国民男神2"));
        System.out.println(map.containsValue("诸葛亮"));

        System.out.println("======================================");
        Set<Map.Entry<String, String>>  entrySet = map.entrySet();
        for (Map.Entry<String, String>  entry:
             entrySet) {
            System.out.println("key - >" + entry.getKey() + "  value - > "+ entry.getValue() );
        }

    }
    public static void main2(String[] args) {
        Collection<String> collection = new ArrayList<>();
        collection.add("hello1");
        collection.add("hello2");
        collection.add("hello3");
        System.out.println(collection);
//        Object[] objects = collection.toArray();

        //object数组不能转换为其他数组
//        String[] objects = (String[]) collection.toArray();
//        System.out.println(Arrays.toString(objects));

        //java中   数组不能进行整体转换
        Object[] intetger = {1,2,3,4,5};
        Integer[] objects = (Integer[]) intetger;


        // Object 类型不能转换为其他类型
//        Object[] intergers = {1,2,3,4,5};
//        Integer[] integer;
//        integer = (Integer) intergers;

//        Object obj = 1;
//        Integer num = (Integer) obj;
//        System.out.println(num);
        // 在java中数组不能整体转换
//        String[] objects1 = (String[]) collection.toArray();
//        System.out.println(Arrays.toString(objects));
//        collection.remove("hello1");
//        System.out.println(collection);
//        collection.clear();
//        System.out.println(collection);
//        System.out.println(collection.size());
//        System.out.println(collection.isEmpty());
//        //不建议这样写
//        Collection collection1 = new ArrayList();
//        collection1.add(1);
//        collection1.add("haha")
    }
    public static void main1(String[] args) {
        Collection<String> collection = new ArrayList<>();
        Collection<String> collection2 = new LinkedList<>();
        Collection<String> collection3 = new Stack<>();

        ArrayList<String> arrayList = new ArrayList<>();
        arrayList.add("hello");
        ArrayList<Integer> arrayList1 = new ArrayList<>();
        arrayList1.add(1);
        ArrayList<Double> arrayList2 = new ArrayList<>();

        List<String> arrayList3 = new ArrayList<>();
    }
}
